package com.denlaku.longan.controller;

import com.denlaku.longan.http.Return;
import com.denlaku.longan.vo.PageBy;
import com.denlaku.longan.vo.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import java.util.List;

/**
 * @author tianx
 */
@RequestMapping("/api/resource")
public interface ResourceController {
	/**
	 * 上传资源
	 *
	 * @param request 请求对象
	 * @return 响应对象
	 */
	@RequestMapping("/upload")
	Return<Resource> upload(MultipartHttpServletRequest request);

	/**
	 * 下载资源
	 *
	 * @param id 资源ID
	 * @param response 响应对象
	 */
	@RequestMapping("/download/{id}")
	void download(@PathVariable("id") Long id, HttpServletResponse response);

	/**
	 * 删除资源
	 *
	 * @param id 资源ID
	 * @return 响应对象
	 */
	@RequestMapping("/delete")
	Return<Void> delete(Long id);

	/**
	 * 分页查询资源
	 *
	 * @param resource 查询参数
	 * @param pageBy 分页参数
	 * @return 响应对象
	 */
	@PostMapping("/page-list")
	Return<List<Resource>> pageList(@RequestBody Resource resource, PageBy pageBy);
}
